#include <csignal>
#include "someip_service.hpp"

hello_world_service * service_ptr(nullptr);

void handle_signal(int _signal) {
    if (service_ptr != nullptr &&
        (_signal == SIGINT || _signal == SIGTERM)) {
            LOG_INF("signal:%d", _signal);
            service_ptr->terminate();
        }
}

int main(int argc, char * argv[]) {
    (void) argc;
    (void) argv;

    LOG_INF("some ip service running");

    hello_world_service hw_srv;
    service_ptr = &hw_srv;
    signal(SIGINT, handle_signal);
    signal(SIGTERM, handle_signal);

    if (hw_srv.init()) {
        hw_srv.start();
        return 0;
    }
    else {
        return 1;
    }
}